<?php
	class Portada{


		private $id;
		private $imagen_portada;
		private $posicion_portada;

		public function __construct($id = 0){
			$this->id = $id;
			if($this->id > 0){
				$sql = "SELECT * FROM portadas WHERE id_portada = ".$id;
				$qry = new Consulta($sql);
				if($qry->NumeroRegistros() > 0){
					$rw = $qry->VerRegistro();
					$this->imagen_portada 	= $rw['imagen_portada'];
					$this->posicion_portada	= $rw['posicion_portada'];
				}					
			}
		}


		public function __get($atributo){
			return $this->$atributo;
		}


		public function getPortadas(){
			$sql = "SELECT * FROM portadas ORDER BY posicion_portada ASC";
			$qry = new Consulta($sql);
			while( $rw = $qry->VerRegistro() ){
				$rst[] = array(
					'id'				=> $rw['id_portada'],
					'imagen_portada'	=> $rw['imagen_portada']
				);
			}
			return $rst;
		}

		public function reordenar($id, $numpos){
			$Query = new Consulta("UPDATE portadas SET posicion_portada = ".$numpos." WHERE id_portada = ".$id."");				
		}
	
	}
?>